
#include <iostream>
#include <string.h>
#include <unistd.h>
#include "RefBase.h"

using namespace std;

using namespace android::RSC;

class Person : public LightRefBase <Person> {
private:
	
public:		
	Person() { 
		cout <<  "Person()" << endl;
	}
	
	~Person()
	{
		cout << "~Person()" <<endl;
	}
	
	void printInfo()
	{
		cout << " just a test function "<< endl;
	}
	
};


template<typename T>
void test_func(sp<T> &other)
{
	sp<T> s = other;
	cout <<"In call test _func,T.StrongCount : " <<s->getStrongCount() <<endl;
	s->printInfo();

}

int main(int argc , char **argv)
{			
	int i;

	
	sp<Person> other = new Person();
	(*other).printInfo();
	cout <<"before call test _func,Person.StrongCount : " <<other->getStrongCount() <<endl;
	
	for(i = 0; i < 2; i++)
	{
		test_func(other);
		cout <<"after call test _func,Person.StrongCount : " <<other->getStrongCount() <<endl;

	}
		

	return 0;
}















